package cn.zy.jboa.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import cn.zy.jboa.dao.CommonDAO;
import cn.zy.jboa.entity.SysEmployee;
import cn.zy.jboa.service.SysEmployeeService;

@Service("sysEmployeeService")
public class SysEmployeeServiceImpl implements SysEmployeeService{
	@Autowired
	@Qualifier("commonDAOImpl")
	CommonDAO commonDao;
	
	public void setCommonDao(CommonDAO commonDao) {
		this.commonDao = commonDao;
	}

	@Override
	public SysEmployee login(SysEmployee sysEmployee) {
		SysEmployee sysEmployee1=null;
		String hql = "from SysEmployee s LEFT JOIN FETCH s.sysDepartment where s.sn='"+sysEmployee.getSn()+"' and s.password = '"+sysEmployee.getPassword()+"'";
		if(commonDao.search(hql).size()>0){
			return (SysEmployee) commonDao.search(hql).get(0);
		}
		return null;
	}

	@Override
	public SysEmployee managerList(String sysDepartmentId) {
		String hql="from SysEmployee where sysPosition.nameEn = 'manager' and sysDepartment.id = "+sysDepartmentId;
		SysEmployee managerList = (SysEmployee) commonDao.search(hql).get(0);
		return managerList;
	}
}
